import App from './App'
import store from './store'
import plugin from './js_sdk/uni-admin/plugin'
import messages from './i18n/index.js'
import * as utils from './utils/index'

const lang = uni.getLocale()
// #ifndef VUE3
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Toast from "vue-toastification";
import {YikAlert} from "@yik_l/alert";
import "vue-toastification/dist/index.css";
import "@yik_l/alert/index.css";

Vue.config.productionTip = false
Vue.use(VueI18n)
// 通过选项创建 VueI18n 实例
const i18n = new VueI18n({
  locale: lang, // 设置地区
  messages, // 设置地区信息
})
Vue.use(plugin)
Vue.use(YikAlert);
Vue.use(Toast, {
    transition: "Vue-Toastification__bounce",
    maxToasts: 20,
    newestOnTop: true,
    filterBeforeCreate: (toast, toasts) => {
      if (toasts.filter(
        t => t.type === toast.type
      ).length !== 0) {
        // Returning false discards the toast
        return false;
      }
      // You can modify the toast if you want
      return toast;
    }
});
App.mpType = 'app'

Vue.prototype.$utils=utils
const app = new Vue({
  i18n,
  store,
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import { createI18n } from 'vue-i18n'
import Layui from '@layui/layui-vue'
import { layer } from  "@layui/layer-vue"
import '@layui/layui-vue/lib/index.css'

window.layer=layer;

export function createApp() {
  const app = createSSRApp(App)
  // const i18n = createI18n({
  //   locale: lang,
  //   messages
  // })
  // app.use(i18n)
  app.use(Layui)
  app.use(plugin)
  app.use(store)

  app.config.globalProperties.$utils = utils; 

  return {
    app
  }
}
// #endif
